package com.bbznb.mapper;

import com.bbznb.entity.Movie;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

@Mapper

public interface UserMapper {
    @Select("select * from movie_info oRder by amount desc LIMIT 15")
    List<Movie> getList();

    @Select("select * from movie_info")
    List<Movie> getMovies(Integer page, Integer size);

    @Select("select * from movie_info where id = #{id}")
    Movie getMovieById(Integer id);

    @Update("update movie_info set amount = amount - 1 where id = #{id}")
    void subtractAmount(Integer id);

    @Update("update user_profile set balance = balance - #{price} where id = #{id} ")
    void subtractUser(Long id, BigDecimal price);

    @Select("SELECT * FROM movie_info WHERE title = #{username}")
    Movie seleteByUsername(String username);
}
